/**
 * A mouse joint is used to make a point on a body track a
 * specified world point. This a soft constraint with a maximum
 * force. This allows the constraint to stretch and without
 * applying huge forces.
 * NOTE: this joint is not documented in the manual because it was
 * developed to be used in the testbed. If you want to learn how to
 * use the mouse joint, look at the testbed.
**/
public class b2MouseJoint extends b2Joint {

	public b2MouseJoint(int addr) {
		super(addr);
	}

	@Override
	public void release() {
		if ( address != 0 ) {
			super.release();
		}
	}

	/**remember to call release() on the returned object*/
	public b2Vec2 GetAnchorA() {
		return new b2Vec2(jni_b2MouseJoint_GetAnchorA(address));
	}

	/**remember to call release() on the returned object*/
	public b2Vec2 GetAnchorB() {
		return new b2Vec2(jni_b2MouseJoint_GetAnchorB(address));
	}

	/**remember to call release() on the returned instance*/
	public b2Vec2 GetReactionForce(float inv_dt) {
		return new b2Vec2(jni_b2MouseJoint_GetReactionForce(address, inv_dt));
	}

	/// Implements b2Joint.
	public float GetReactionTorque(float inv_dt) {
		return jni_b2MouseJoint_GetReactionTorque(address, inv_dt);
	}

	/// Use this to update the target point.
	public void SetTarget(final b2Vec2 target) {
		jni_b2MouseJoint_SetTarget(address, target.address);
	}

	/**return the internal b2Vec2 object, don't call release()*/
	public b2Vec2 GetTarget() {
		return new b2Vec2(jni_b2MouseJoint_GetTarget(address));
	}

	/// Set/get the maximum force in Newtons.
	public void SetMaxForce(float force) {
		jni_b2MouseJoint_SetMaxForce(address, force);
	}

	public float GetMaxForce() {
		return jni_b2MouseJoint_GetMaxForce(address);
	}

	/// Set/get the frequency in Hertz.
	public void SetFrequency(float hz) {
		jni_b2MouseJoint_SetFrequency(address, hz);
	}

	public float GetFrequency() {
		return jni_b2MouseJoint_GetFrequency(address);
	}

	/// Set/get the damping ratio (dimensionless).
	public void SetDampingRatio(float ratio) {
		jni_b2MouseJoint_SetDampingRatio(address, ratio);
	}

	public float GetDampingRatio() {
		return jni_b2MouseJoint_GetDampingRatio(address);
	}

	/// The mouse joint does not support dumping.
	public void Dump(){
		//do nothing
	}

	private static native int jni_b2MouseJoint_GetAnchorA(int me);
	private static native int jni_b2MouseJoint_GetAnchorB(int me);
	private static native int jni_b2MouseJoint_GetReactionForce(int me, float inv_dt);
	private static native float jni_b2MouseJoint_GetReactionTorque(int me, float inv_dt);
	private static native void jni_b2MouseJoint_SetTarget(int me, int target);
	private static native int jni_b2MouseJoint_GetTarget(int me);
	private static native void jni_b2MouseJoint_SetMaxForce(int me, float force);
	private static native float jni_b2MouseJoint_GetMaxForce(int me);
	private static native void jni_b2MouseJoint_SetFrequency(int me, float hz);
	private static native float jni_b2MouseJoint_GetFrequency(int me);
	private static native void jni_b2MouseJoint_SetDampingRatio(int me, float ratio);
	private static native float jni_b2MouseJoint_GetDampingRatio(int me);
}
